package com.autotest.nore.controller;

import com.autotest.nore.common.utils.PageUtils;
import com.autotest.nore.common.utils.Pager;
import com.autotest.nore.dto.FunctionDTO;
import com.autotest.nore.service.FunctionService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/autotest/function")
public class FunctionController {

    @Autowired
    private FunctionService functionService;


    @PostMapping("/list/{goPage}/{pageSize}")
    public Pager<List<FunctionDTO>> getFunctionList(@PathVariable int goPage, @PathVariable int pageSize) {
        Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
        return PageUtils.setPageInfo(page, functionService.getFunctionList());
    }
    @PostMapping("/list/{type}/{goPage}/{pageSize}")
    public Pager<List<FunctionDTO>> getFunctionListByType(@PathVariable String type,@PathVariable int goPage, @PathVariable int pageSize) {
        Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
        return PageUtils.setPageInfo(page, functionService.getFunctionListByType(type));
    }

    @GetMapping("/type/list")
    public List<String> getTypeList(){
        return functionService.getType();
    }





}
